<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * FormativeLab
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		FormativeLab
 * @author		FormativeLab Dev Team
 * @copyright	Copyright (c) 2011 - 2013, FormativeLab, Inc.
 * @license		http://www.formativesoft.com/license/
 * @link		http://www.formativesoft.com/
 * @since		Version 2.0
 * @filesource ./application/libraries/AccessControlList.php
 */

// ------------------------------------------------------------------------

/**
 * FormativeLab AccessControlList Library
 *
 * @package		FormativeLab
 * @subpackage	libraries
 * @category	libraries
 * @author		Formative Soft Ltd
 * @link		http://www.formativesoft.com/
 */

// ------------------------------------------------------------------------

class AccessControlList{

	private $controller;
	
	private $input;
	private $output;
	private $session;
	
	
	private $readFailureMessage;
	private $writeFaliureMessage;
	private $deleteFailureMessage;
	private $grantFailureMessage;
	
	static $securityConfigMapping = array(
		'readFailureMessage'	=> 'read_failure_message',
		'writeFaliureMessage'	=> 'write_faliure_message',
		'deleteFailureMessage'	=> 'delete_failure_message',
		'grantFailureMessage'	=> 'grant_failure_message'
	);

	static $helpers 		= array('security', 'url', 'method', 'resource');
	static $libraries		= array('form_validation','session');
	
	const SECURITY_CFG  = 'security';
	
	const READ 			= 1;
	const WRITE			= 2;
	const DELETE		= 4;
	const GRANT			= 8;
	
	public function __construct(){
        $this->controller = &get_instance();
		$this->loadSecurityConfig();
		
		$this->controller->load->helper(self::$helpers);
        $this->controller->load->library(self::$libraries);
		
		$this->input  		= &$this->controller->input;
		$this->output 		= &$this->controller->output;
		$this->session 		= &$this->controller->session;
    }
	
	private function loadSecurityConfig(){
		$this->controller->config->load(self::SECURITY_CFG);
		foreach(self::$securityConfigMapping as $property => $key){
			$this->{$property} = $this->controller->config->item($key);
		}
	}
	
}

/* End of file AccessControlList.php */
/* Location: ./application/libraries/AccessControlList.php */